home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / pango-1.0 / pango / pango-engine.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-25  |  13.4 KB  |  372 lines

  1. /* Pango
  2.  * pango-engine.h: Engines for script and language specific processing
  3.  *
  4.  * Copyright (C) 2000,2003 Red Hat Software
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Library General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
  14.  * Library General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Library General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. #ifndef __PANGO_ENGINE_H__
  23. #define __PANGO_ENGINE_H__
  24.  
  25. #include <pango/pango-types.h>
  26. #include <pango/pango-item.h>
  27. #include <pango/pango-font.h>
  28. #include <pango/pango-glyph.h>
  29. #include <pango/pango-script.h>
  30.  
  31. G_BEGIN_DECLS
  32.  
  33. #ifdef PANGO_ENABLE_ENGINE
  34.  
  35. /* Module API */
  36.  
  37. #define PANGO_RENDER_TYPE_NONE "PangoRenderNone"
  38.  
  39. #define PANGO_TYPE_ENGINE              (pango_engine_get_type ())
  40. #define PANGO_ENGINE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_ENGINE, PangoEngine))
  41. #define PANGO_IS_ENGINE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_ENGINE))
  42. #define PANGO_ENGINE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_ENGINE, PangoEngineClass))
  43. #define PANGO_IS_ENGINE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ENGINE))
  44. #define PANGO_ENGINE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ENGINE, PangoEngineClass))
  45.  
  46. typedef struct _PangoEngine PangoEngine;
  47. typedef struct _PangoEngineClass PangoEngineClass;
  48.  
  49. /**
  50.  * PangoEngine:
  51.  *
  52.  * #PangoEngine is the base class for all types of language and
  53.  * script specific engines. It has no functionality by itself.
  54.  **/
  55. struct _PangoEngine
  56. {
  57.   /*< private >*/
  58.   GObject parent_instance;
  59. };
  60.  
  61. /**
  62.  * PangoEngineClass:
  63.  *
  64.  * Class structure for #PangoEngine
  65.  **/
  66. struct _PangoEngineClass
  67. {
  68.   /*< private >*/
  69.   GObjectClass parent_class;
  70. };
  71.  
  72. GType pango_engine_get_type (void) G_GNUC_CONST;
  73.  
  74. #define PANGO_ENGINE_TYPE_LANG "PangoEngineLang"
  75.  
  76. #define PANGO_TYPE_ENGINE_LANG              (pango_engine_lang_get_type ())
  77. #define PANGO_ENGINE_LANG(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_ENGINE_LANG, PangoEngineLang))
  78. #define PANGO_IS_ENGINE_LANG(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_ENGINE_LANG))
  79. #define PANGO_ENGINE_LANG_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_ENGINE_LANG, PangoEngineLangClass))
  80. #define PANGO_IS_ENGINE_LANG_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ENGINE_LANG))
  81. #define PANGO_ENGINE_LANG_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ENGINE_LANG, PangoEngineLangClass))
  82.  
  83. typedef struct _PangoEngineLangClass PangoEngineLangClass;
  84.  
  85. /**
  86.  * PangoEngineLang:
  87.  *
  88.  * The #PangoEngineLang class is implemented by engines that
  89.  * customize the rendering-system independent part of the
  90.  * Pango pipeline for a particular script or language. For
  91.  * instance, a custom #PangoEngineLang could be provided for
  92.  * Thai to implement the dictionary-based word boundary
  93.  * lookups needed for that language.
  94.  **/
  95. struct _PangoEngineLang
  96. {
  97.   /*< private >*/
  98.   PangoEngine parent_instance;
  99. };
  100.  
  101. /**
  102.  * PangoEngineLangClass:
  103.  * @script_break: Provides a custom implementation of pango_break().
  104.  *  if this is %NULL, pango_default_break() will be used.
  105.  *
  106.  * Class structure for #PangoEngineLang
  107.  **/
  108. struct _PangoEngineLangClass
  109. {
  110.   /*< private >*/
  111.   PangoEngineClass parent_class;
  112.   
  113.   /*< public >*/
  114.   void (*script_break) (PangoEngineLang *engine,
  115.             const char    *text,
  116.             int            len,
  117.             PangoAnalysis *analysis,
  118.             PangoLogAttr  *attrs,
  119.                         int            attrs_len);
  120. };
  121.  
  122. GType pango_engine_lang_get_type (void) G_GNUC_CONST;
  123.  
  124. #define PANGO_ENGINE_TYPE_SHAPE "PangoEngineShape"
  125.  
  126. #define PANGO_TYPE_ENGINE_SHAPE              (pango_engine_shape_get_type ())
  127. #define PANGO_ENGINE_SHAPE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_ENGINE_SHAPE, PangoEngineShape))
  128. #define PANGO_IS_ENGINE_SHAPE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_ENGINE_SHAPE))
  129. #define PANGO_ENGINE_SHAPE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_ENGINE_SHAPE, PangoEngine_ShapeClass))
  130. #define PANGO_IS_ENGINE_SHAPE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ENGINE_SHAPE))
  131. #define PANGO_ENGINE_SHAPE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ENGINE_SHAPE, PangoEngineShapeClass))
  132.  
  133. typedef struct _PangoEngineShapeClass PangoEngineShapeClass;
  134.  
  135. /**
  136.  * PangoEngineShape
  137.  *
  138.  * The #PangoEngineShape class is implemented by engines that
  139.  * customize the rendering-system dependent part of the
  140.  * Pango pipeline for a particular script or language.
  141.  * A #PangoEngineShape implementation is then specific to both
  142.  * a particular rendering system or group of rendering systems
  143.  * and to a particular script. For instance, there is one
  144.  * #PangoEngineShape implementation to handling shaping Arabic
  145.  * for Fontconfig-based backends.
  146.  **/
  147. struct _PangoEngineShape
  148. {
  149.   PangoEngine parent_instance;
  150. };
  151.  
  152. /**
  153.  * PangoEngineShapeClass:
  154.  * @script_shape: Given a font, a piece of text, and a #PangoAnalysis
  155.  *   structure, converts characters to glyphs and positions the
  156.  *   resulting glyphs. The results are stored in the #PangoGlyphString
  157.  *   that is passed in. (The implementation should resize it
  158.  *   appropriately using pango_glyph_string_set_size()). All fields
  159.  *   of the @log_clusters and @glyphs array must be filled in, with
  160.  *   the exception that Pango will automatically generate
  161.  *   <literal>glyphs->glyphs[i].attr.is_cluster_start</literal>
  162.  *   using the @log_clusters array. Each input character must occur in one
  163.  *   of the output logical clusters;
  164.  *   if no rendering is desired for a character, this may involve
  165.  *   inserting glyphs with the #PangoGlyph ID 0, which is guaranteed never
  166.  *   to render.
  167.  * @covers: Returns the characters that this engine can cover
  168.  *   with a given font for a given language. If not overridden, the default
  169.  *   implementation simply returns the coverage information for the
  170.  *   font itself unmodified.
  171.  *
  172.  * Class structure for #PangoEngineShape
  173.  **/
  174. struct _PangoEngineShapeClass
  175. {
  176.   /*< private >*/
  177.   PangoEngineClass parent_class;
  178.   
  179.   /*< public >*/
  180.   void (*script_shape) (PangoEngineShape *engine,
  181.             PangoFont        *font,
  182.             const char       *text,
  183.             int               length,
  184.             PangoAnalysis    *analysis,
  185.             PangoGlyphString *glyphs);
  186.   PangoCoverageLevel (*covers)   (PangoEngineShape *engine,
  187.                   PangoFont        *font,
  188.                   PangoLanguage    *language,
  189.                   gunichar          wc);
  190. };
  191.  
  192. GType pango_engine_shape_get_type (void) G_GNUC_CONST;
  193.  
  194. typedef struct _PangoEngineInfo PangoEngineInfo;
  195. typedef struct _PangoEngineScriptInfo PangoEngineScriptInfo;
  196.  
  197. struct _PangoEngineScriptInfo 
  198. {
  199.   PangoScript script;
  200.   gchar *langs;
  201. };
  202.  
  203. struct _PangoEngineInfo
  204. {
  205.   gchar *id;
  206.   gchar *engine_type;
  207.   gchar *render_type;
  208.   PangoEngineScriptInfo *scripts;
  209.   gint n_scripts;
  210. };
  211.  
  212. /**
  213.  * script_engine_list:
  214.  * @engines: location to store a pointer to an array of engines.
  215.  * @n_engines: location to store the number of elements in @engines.
  216.  * 
  217.  * Function to be provided by a module to list the engines that the
  218.  * module supplies. The function stores a pointer to an array
  219.  * of #PangoEngineInfo structures and the length of that array in
  220.  * the given location.
  221.  *
  222.  * Note that script_engine_init() will not be called before this
  223.  * function.
  224.  **/
  225. void script_engine_list (PangoEngineInfo **engines,
  226.              int              *n_engines);
  227.  
  228. /**
  229.  * script_engine_init:
  230.  * @module: a #GTypeModule structure used to associate any
  231.  *  GObject types created in this module with the module.
  232.  * 
  233.  * Function to be provided by a module to register any
  234.  * GObject types in the module.
  235.  **/
  236. void script_engine_init (GTypeModule *module);
  237.  
  238.  
  239. /**
  240.  * script_engine_exit:
  241.  * 
  242.  * Function to be provided by the module that is called
  243.  * when the module is unloading. Frequently does nothing.
  244.  **/
  245. void script_engine_exit (void);
  246.  
  247. /**
  248.  * script_engine_create:
  249.  * @id: the ID of an engine as reported by script_engine_list.
  250.  * 
  251.  * Function to be provided by the module to create an instance
  252.  * of one of the engines implemented by the module.
  253.  * 
  254.  * Return value: a newly created #PangoEngine of the specified
  255.  *  type, or %NULL if an error occurred. (In normal operation,
  256.  *  a module should not return %NULL. A %NULL return is only
  257.  *  acceptable in the case where system misconfiguration or
  258.  *  bugs in the driver routine are encountered.)
  259.  **/
  260. PangoEngine *script_engine_create (const char *id);
  261.  
  262. /* Utility macro used by PANGO_ENGINE_LANG_DEFINE_TYPE and
  263.  * PANGO_ENGINE_LANG_DEFINE_TYPE
  264.  */
  265. #define PANGO_ENGINE_DEFINE_TYPE(name, prefix, class_init, instance_init, parent_type) \
  266. static GType prefix ## _type;                          \
  267. static void                                  \
  268. prefix ## _register_type (GTypeModule *module)                  \
  269. {                                      \
  270.   static const GTypeInfo object_info =                      \
  271.     {                                      \
  272.       sizeof (name ## Class),                          \
  273.       (GBaseInitFunc) NULL,                          \
  274.       (GBaseFinalizeFunc) NULL,                          \
  275.       (GClassInitFunc) class_init,                      \
  276.       (GClassFinalizeFunc) NULL,                      \
  277.       NULL,           /* class_data */                      \
  278.       sizeof (name),                                \
  279.       0,             /* n_prelocs */                      \
  280.       (GInstanceInitFunc) instance_init,                  \
  281.     };                                      \
  282.                                       \
  283.   prefix ## _type =  g_type_module_register_type (module, parent_type,      \
  284.                               # name,          \
  285.                           &object_info, 0);      \
  286. }
  287.  
  288. /**
  289.  * PANGO_ENGINE_LANG_DEFINE_TYPE:
  290.  * @name: Name of the the type to register (for example:, <literal>ArabicEngineFc</literal>
  291.  * @prefix: Prefix for symbols that will be defined (for example:, <literal>arabic_engine_fc</literal>
  292.  * @class_init: Class initialization function for the new type, or %NULL
  293.  * @instance_init: Instance initialization function for the new type, or %NULL
  294.  *
  295.  * Outputs the necessary code for GObject type registration for a
  296.  * #PangoEngineLang class defined in a module. Two static symbols
  297.  * are defined.
  298.  *
  299.  * <programlisting>
  300.  *  static GType <replaceable>prefix</replaceable>_type;
  301.  *  static void <replaceable>prefix</replaceable>_register_type (GTypeModule module);
  302.  * </programlisting>
  303.  *
  304.  * The <function><replaceable>prefix</replaceable>_register_type()</function>
  305.  * function should be called in your script_engine_init() function for
  306.  * each type that your module implements, and then your script_engine_create()
  307.  * function can create instances of the object as follows:
  308.  *
  309.  * <informalexample><programlisting>
  310.  *  PangoEngine *engine = g_object_new (<replaceable>prefix</replaceable>_type, NULL);
  311.  * </programlisting></informalexample>
  312.  **/
  313. #define PANGO_ENGINE_LANG_DEFINE_TYPE(name, prefix, class_init, instance_init)    \
  314.   PANGO_ENGINE_DEFINE_TYPE (name, prefix,                \
  315.                 class_init, instance_init,            \
  316.                             PANGO_TYPE_ENGINE_LANG)
  317.  
  318. /**
  319.  * PANGO_ENGINE_SHAPE_DEFINE_TYPE:
  320.  * @name: Name of the the type to register (for example:, <literal>ArabicEngineFc</literal>
  321.  * @prefix: Prefix for symbols that will be defined (for example:, <literal>arabic_engine_fc</literal>
  322.  * @class_init: Class initialization function for the new type, or %NULL
  323.  * @instance_init: Instance initialization function for the new type, or %NULL
  324.  *
  325.  * Outputs the necessary code for GObject type registration for a
  326.  * #PangoEngineShape class defined in a module. Two static symbols
  327.  * are defined.
  328.  *
  329.  * <programlisting>
  330.  *  static GType <replaceable>prefix</replaceable>_type;
  331.  *  static void <replaceable>prefix</replaceable>_register_type (GTypeModule module);
  332.  * </programlisting>
  333.  *
  334.  * The <function><replaceable>prefix</replaceable>_register_type()</function>
  335.  * function should be called in your script_engine_init() function for
  336.  * each type that your module implements, and then your script_engine_create()
  337.  * function can create instances of the object as follows:
  338.  *
  339.  * <informalexample><programlisting>
  340.  *  PangoEngine *engine = g_object_new (<replaceable>prefix</replaceable>_type, NULL);
  341.  * </programlisting></informalexample>
  342.  **/
  343. #define PANGO_ENGINE_SHAPE_DEFINE_TYPE(name, prefix, class_init, instance_init)    \
  344.   PANGO_ENGINE_DEFINE_TYPE (name, prefix,                \
  345.                 class_init, instance_init,            \
  346.                             PANGO_TYPE_ENGINE_SHAPE)
  347.  
  348. /* Macro used for possibly builtin Pango modules. Not useful
  349.  * for externally build modules. If we are compiling a module standaline,
  350.  * then we name the entry points script_engine_list, etc. But if we
  351.  * are compiling it for inclusion directly in Pango, then we need them to
  352.  * to have distinct names for this module, so we prepend a prefix.
  353.  *
  354.  * The two intermediate macros are to deal with details of the C
  355.  * preprocessor; token pasting tokens must be function arguments,
  356.  * and macro substitution isn't used on function arguments that
  357.  * are used for token pasting.
  358.  */
  359. #ifdef PANGO_MODULE_PREFIX
  360. #define PANGO_MODULE_ENTRY(func) _PANGO_MODULE_ENTRY2(PANGO_MODULE_PREFIX,func)
  361. #define _PANGO_MODULE_ENTRY2(prefix,func) _PANGO_MODULE_ENTRY3(prefix,func)
  362. #define _PANGO_MODULE_ENTRY3(prefix,func) prefix##_script_engine_##func
  363. #else
  364. #define PANGO_MODULE_ENTRY(func) script_engine_##func
  365. #endif
  366.  
  367. #endif /* PANGO_ENABLE_ENGINE */
  368.  
  369. G_END_DECLS
  370.  
  371. #endif /* __PANGO_ENGINE_H__ */
  372.